package cn.wizzer.app.web.modules.controllers.user;

import cn.wizzer.app.user.modules.services.TrialFundService;
import cn.wizzer.app.web.commons.filter.ApiTokenFilter;
import cn.wizzer.framework.util.Result;
import com.alibaba.dubbo.config.annotation.Reference;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.mvc.Mvcs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.Ok;

/**
 * 体验金
 */
@IocBean
@At("/api/user/trialFund")
public class ApiTrialFundController {

    @Inject
    @Reference
    private TrialFundService trialFundService;

    /**
     * 申请体验金
     *
     * @return
     */
    @At("/apply")
    @Ok("json")
    @Filters(@By(type = ApiTokenFilter.class))
    public Object apply() {
        String appid = Mvcs.getReq().getHeader("appid");
        String ip = Lang.getIP(Mvcs.getReq());
        trialFundService.apply(appid, ip);
        return Result.success();
    }

}
